package com.gedi.consumer.controller;


import com.springcloud.albaba.common.entity.Commentresult;
import com.springcloud.albaba.common.entity.Payment;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * @Author:RenPu
 * @Date: 2020/6/29 12:38
 * @Version: 1.0
 * @description:
 */

@RestController
@Slf4j
public class ConsumerController {

    @Resource
    private RestTemplate restTemplate;




    public static final String PAY_MENT="http://localhost:8081";


    @GetMapping("/consumer/payment/create")
    public Commentresult<Payment> create(@RequestBody Payment payment){

       return restTemplate.postForObject(PAY_MENT+"/Payment/create",payment,Commentresult.class);

    }

    @GetMapping("/consumer/payment/get/{id}")
    public Commentresult<Payment> get(@PathVariable(value = "id") Long id){

        return restTemplate.getForObject(PAY_MENT+"/Payment/selectPaymentById/"+id,Commentresult.class);

    }



}
